package com.efuture.androidmvvmdemo.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.efuture.androidmvvmdemo.base.BaseModel
import com.efuture.androidmvvmdemo.net.ApiParameter
import com.efuture.androidmvvmdemo.net.NetService
import com.efuture.netrequestdemo.bean.User
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

/**

 *@description:TODO
 * @author: zhaoshanshan
 * @date: 2022/3/27 1:14 下午

 */
class RegisterViewModel: BaseModel() {

    val registerUserData = MutableLiveData<User>()

    fun registerUser(userName: String, passWord: String) {

        viewModelScope.launch (Dispatchers.Main){
            //登录
            val registerUser: User? = NetService.request(ApiParameter.registerUser(userName,passWord,passWord),"正在注册中...")
            registerUserData.postValue(registerUser)
        }

    }
}